#ifndef __MAINFRAME_HPP__
#define __MAINFRAME_HPP__

/**
 *  This file is part of PennerBot
 *
 *  Copyright (C) 2010 microkernel
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <wx/wx.h>
#include <wx/taskbar.h>

#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/shared_ptr.hpp>

#include <core/bot.hpp>
#include <core/config.hpp>
#include <core/updatecheck.hpp>

#include <gui/wxformb_gui.h>

namespace PBot
{
namespace GUI
{

class StatusListener;

class MainFrame : public FrmPBot
{
public:
    MainFrame(Core::Config* cfg);
    ~MainFrame();

    void AddStatusMessage(const std::string& msg);
    void ThreadDo();

    void OnTimer(wxTimerEvent& event);
    void OnUpdateTimer(wxTimerEvent& event);

    void OnClose(wxCloseEvent& event);
    void OnIconize(wxIconizeEvent& event);
    void OnBtnAbout(wxCommandEvent& event);
    void OnBtnDonate(wxCommandEvent& event);
    void OnBtnSettings(wxCommandEvent& event);
    void OnBtnWebsite(wxCommandEvent& event);


protected:
    DECLARE_EVENT_TABLE()

private:
    void SafeAddStatusMessage(wxCommandEvent&);
    void UnsafeMessageBox(wxCommandEvent& event);

    StatusListener& listener;
    Core::Config *cfg;
    Core::Bot *bot;

    Core::UpdateCheck* updateCheck;

    bool running;

    boost::shared_ptr<boost::thread> thread;

    wxTimer timer;

    class TrayIcon : public wxTaskBarIcon
    {
    public:
        TrayIcon(MainFrame *parent);
        virtual ~TrayIcon();
        virtual wxMenu* CreatePopupMenu();

    protected:
        DECLARE_EVENT_TABLE();

    private:
        void MenuQuit(wxCommandEvent& event);
        void OnTrayIconLeftUp(wxTaskBarIconEvent& event);

        MainFrame *parent;

    } trayIcon;

public:

    /* BottleCollect */
    wxString BCstatusText;
    unsigned int BCtime;
    unsigned int BCfullTime;
    bool BCcollecting;
    int count;
};


}
}

#endif // __MAINFRAME_HPP__
